<template>
	<!-- 车辆审核 -->
	<div>
		<div class="edit-top">
			审核信息
			<i class="el-icon-close" @click='cancel'></i>
		</div>
		<div class="edit-content">
			<div class="edit-title">车辆信息</div>
			<div class="edit-item">
				<label>车架号</label><input v-model="info.vin" disabled="disabled" type="text" />
			</div>

			<div class="edit-item">
				<label>型号</label><input v-model="info.model" disabled="disabled" type="text" />
			</div>

			<div class="edit-item">
				<label>发动机号</label><input v-model="info.engineCode" disabled="disabled" type="text" />
			</div>
			<div class="edit-item">
				<label>车辆类型</label><select v-model="info.vehicleType" disabled="disabled">
					<option v-for='item in dict.vehicleType' :value="item.value">{{item.type}}</option>
				</select>
			</div>
			<div class="edit-item">
				<label>生产厂家</label><input v-model="info.manufacturer" disabled="disabled" type="text" />
			</div>
			<div class="edit-item">
				<label>随车电池包号</label><input v-model="info.initBatteryCode" disabled="disabled" type="text" />
			</div>
			<template v-if="status > 1">
				<div class="edit-item">
					<label>行驶证</label><input v-model="info.drivingLicenseNum" disabled="disabled" type="text" />
				</div>
				<div class="edit-item">
					<label>车牌号</label><input v-model="info.licensePlateNumber" disabled="disabled" type="text" />
				</div>
				<div class="edit-item">
					<label>车牌类型</label><select v-model="info.licensePlateType" disabled="disabled">
						<option v-for='item in dict.licensePlateType' :value="item.value">{{item.type}}</option>
					</select>
				</div>
				<div class="edit-item">
					<label>车主姓名</label><input v-model="info.ownerName" type="text" :disabled="flag == 1" />
				</div>
				<div class="edit-item">
					<label>车主身份证</label><input v-model="info.ownerIdcard" type="text" :disabled="flag == 1" />
				</div>
				<div class="edit-item">
					<label>车主手机号</label><input v-model="info.ownerPhoneNum" type="text" :disabled="flag == 1" />
				</div>
				<div class="edit-item">
					<label>联系人手机</label><input v-model="info.contactsPhoneNum" type="text" :disabled="flag == 1" />
				</div>
				<div class="edit-item">
					<label>使用性质</label><select v-model="info.property" disabled="disabled">
						<option v-for='item in dict.property' :value="item.value">{{item.type}}</option>
					</select>
				</div>
				<div class="edit-item">
					<label>产权人类型</label><select v-model="info.ownerType" disabled="disabled">
						<option v-for='item in dict.ownerType' :value="item.value">{{item.type}}</option>
					</select>
				</div>
				<div class="edit-item">
					<label>产权证书号</label><input v-model="info.propertyRightCode" disabled="disabled" type="text" />
				</div>

			</template>


		</div>
		<div class="edit-bottom">
			<el-button @click='save(1)' type="primary">同意</el-button>
			<el-button @click='save(2)' type="info">拒绝</el-button>
			<el-button @click='save(0)' type="info">关闭</el-button>
		</div>
	</div>
</template>

<script>
	import Global from '@/components/Global.vue'
	export default {
		props: ['id', 'status','flag'],
		data() {
			return {
				dict: '',
				info: {
					vin: '',
					vehicleType: '',
					status: 0,
					model: '',
					manufacturer: '',
					initBatteryCode: '',
					engineCode: '',
					clerkUserId: '',
					clerkUserName: '',
					clerkDate: '',
					// licensePlateNumber: '',
					// drivingLicenseNum: '',
					ownerIdcard: '',
					ownerName: '',
					ownerPhoneNum: '',
					// switchNum:'0',
					// auditUserId:'',
					// auditUserName:'',
					// auditDate:'',
					// licensePlateType:'',
					// property:'',
					// propertyRightCode:'',
					// ownerType:'',
					// contactsName:'',
					// contactsPhoneNum:'',
					// salesInfoUserId:'',
					// salesInfoUserName:'',
					// salesInfoDate:'',
					// salesInfoAuditUserId:'',
					// salesInfoAuditUserName:'',
					// salesInfoAuditDate:''
				},
				processId: ''

			}
		},
		mounted() {
			this.get_dict();
			this.get_info();
		},
		methods: {
			get_dict() {
				var self = this;
				this.$axios.get(this.$global.serverIp + 'admin/dict/findDict?keyword=vehicle')
				  .then(function (res) {
					  if(res != '')
						self.dict = res.data;
				  })
			},
			get_info() {
				var self = this;
				this.$axios.get(this.$global.serverIp + 'vehicle/vehicle/info/' + this.id)
					.then(function(res) {
						if (res != ''){
							self.info = res.data.sysflow.object;
							self.processId = res.data.sysflow.processId;
						}
					})
			},
			save(status) {
				var self = this;
				this.$axios.post(this.$global.serverIp + 'vehicle/vehicle/verifyPass', {
				"id": self.id,
				"processId": self.processId,
				"status": status
				  })
				  .then(function (res) {
					  if(res != ''){
						 self.success('审核成功');
					  }
						
				  })
				
			},
			success(content) {
				var self = this;
				this.$alert(content, '提示', {
					confirmButtonText: '确定',
					callback: action => {
						self.$emit("saveEdit", 2);
					}
				});
			},
			
			cancel() {
				this.$emit("saveEdit", 1);
			}
		}
	}
	import '@/assets/css/edit.css'
</script>
